package com.framework.controller;

import com.framework.entity.sys.SysCard;
import com.framework.exception.util.RespResult;
import com.framework.service.SysCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述: 信用卡控制器
 *
 * @author ck
 * @date 2018/11/9 15:54
 */
@RestController
@Api(value="信用卡模块",tags={"信用卡模块"})
@RequestMapping(value = "card")
public class CardController {

	@Autowired
	private SysCardService cardService;

	/**
	 * 查询是否可以申请信用卡
	 * @param agentId
	 * @param bankType
	 * @param phone
	 * @return
	 */
	@GetMapping("notValidate/queryIsCard")
	@ApiOperation("查询是否可以申请信用卡")
	public RespResult queryIsCard(Long agentId,String bankType,String phone) {
		boolean isCardRepeat = cardService.queryIsCardRepeat(agentId,bankType,phone);
		return RespResult.ok().put("isCardRepeat",isCardRepeat);
	}

	/**
	 * 提交信用卡
	 * @return
	 */
	@PostMapping("notValidate/insertCard")
	@ApiOperation("提交信用卡")
	public RespResult insertCard(SysCard sysCard) {
		cardService.insertCard(sysCard);
		return RespResult.ok();
	}

	/**
	 * 查询出玖富万卡的id
	 * @param agentId
	 * @return
	 */
	@GetMapping("notValidate/queryShopId")
	@ApiOperation("查询出玖富万卡的id")
	public RespResult queryShopId(Long agentId) {
		String shopId = cardService.queryShopId(agentId);
		return RespResult.ok().put("shopId",shopId);
	}
}
